// exception.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <boost/exception.hpp>
#include <string>
#include <iostream>

using namespace boost;
using namespace std;

#include <toftlib/exception/ToftException.hpp>

typedef error_info<struct tag_example, string> errorMsg;

class MyException : public toftlib::ToftException
{
public:
    MyException(const char* errorMsg) : ToftException(errorMsg)
    {
    }
};


int _tmain(int argc, _TCHAR* argv[])
{

    try
    {
        BOOST_THROW_EXCEPTION( MyException("Standard error") << errorMsg("Hello, I am an exception") );
        //BOOST_THROW_EXCEPTION(boost::enable_error_info(std::exception("HELLO")));
    }
    
    catch(toftlib::ToftException& ex)
    {
        if( boost::shared_ptr<string const> err = boost::get_error_info<errorMsg>(ex) )
        {
            std::cerr << "Error message: " << *err << std::endl;
            std::cerr << "Diagnostic information: " << std::endl << diagnostic_information(ex) << std::endl;
            std::cerr << "What: " << ex.what() << std::endl;
        }

    }
    
    catch(std::exception& ex)
    {

        std::cerr << "Reported What: " << ex.what() << std::endl;
    }


	return 0;
}

